<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>挂号预约</title>
    <!--浏览器小图标-->
    <link rel="shortcut icon" href="/img/favicon.png">
    <!--自定义样式-->
    <link rel="stylesheet" href="/css/index.css">
    <!-- 引入Element UI样式 -->
    <link rel="stylesheet" href="/element/element-ui.css">
    <!--自定义样式-->
    <link rel="stylesheet" href="/css/orders.css">
</head>
<body>
<div>
    <el-container>
        <!--自定义标签-->
        <el-header style="position: fixed;width: 100%;z-index: 1">
            <index-header></index-header>
        </el-header>
        <el-main>
            <el-row>
                <el-col offset="2" span="20">
                    <el-row style="margin-top: 55px">
                        <el-col span="4">
                            <index-left-card></index-left-card>
                        </el-col>
                        <el-col span="20" v-loading="loading">
                            <!--右边卡片-->
                            <el-card shadow="hover">
                                <el-row v-if="dataCode===1007">
                                    <el-alert
                                            title="该科室近期无号源，请改日再约"
                                            type="warning">
                                    </el-alert>
                                    <el-empty description="暂无排班数据"></el-empty>
                                </el-row>
                                <el-row v-else v-loading="loading">
                                    <!--页面科室名称-->
                                    <el-col><h3 style="color: black;text-align: left">{{deptname}}</h3></el-col>
                                    <!--当前时间段-->
                                    <el-col style="margin-top: 20px;">
                                        <p style="text-align: center;color:#000;">
                                            {{new Date().getFullYear()}}年{{new Date().getMonth() + 1}}月</p>
                                    </el-col>
                                    <!--挂号卡片-->
                                    <el-col style="margin-top: 20px;">
                                        <el-row gutter="20">
                                            <el-col span="3" v-for="(future,i) in futureWeek">
                                                <el-link @click="">
                                                    <el-card :id="'dataSource_' + i"
                                                             @click.native="setClickCardStyle(i)">
                                                        <div slot="header" class="clearfix">
                                                            <span style="font-size: 14px">{{future.date}}</span>
                                                            <span style="font-size: 14px">&nbsp;&nbsp;{{future.week}}</span>
                                                        </div>
                                                        <div v-if="future.totalCount===0 && future.surplus===0">
                                                            <p>无号</p>
                                                        </div>
                                                        <div v-if="future.totalCount>0 && future.surplus>0">
                                                            <p>有号</p>
                                                        </div>
                                                        <div v-else-if="future.totalCount>0 && future.surplus===0">
                                                            <p>满号</p>
                                                        </div>
                                                    </el-card>
                                                </el-link>
                                            </el-col>
                                        </el-row>
                                    </el-col>
                                    <!--提示-->
                                    <el-col style="text-align: center;margin-top: 20px">
                                        <el-row>
                                            <el-col>
                                                <p style="text-align: left">号源</p>
                                            </el-col>
                                            <el-col v-for="(doctor,i) in doctorData">
                                                <el-descriptions style="margin-top: 20px;text-align: center"
                                                                 :title="doctor.nickname +' | '+ doctor.doctorNo"
                                                                 column="7" :colon="false"
                                                                 v-show="doctor.sourcetotal!==0">
                                                    <el-descriptions-item label="号源总量">
                                                        <p>{{doctor.sourcetotal}}</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item label="职称">
                                                        <p>{{doctor.jobTitle}}</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item label="科室">
                                                        <p>{{doctor.deptname}}</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item label="排班日期">
                                                        <p>{{doctor.schedulTime}}</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item label="状态">
                                                        <p v-if="doctor.sourcesurplus>0" style="color:#67C23A;">
                                                            可预约</p>
                                                        <p v-else-if="doctor.sourcesurplus===0" style="color:#F56C6C;">
                                                            不可预约</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item label="费用">
                                                        <p style="color: #3a8ee6">￥ {{doctor.expenses}}</p>
                                                    </el-descriptions-item>
                                                    <el-descriptions-item>
                                                        <el-button @click="booking(i)" type="primary"
                                                                   v-show="doctor.sourcesurplus!==0">
                                                            <h3>剩余 {{doctor.sourcesurplus}}</h3>
                                                        </el-button>
                                                        <el-button type="info" disabled
                                                                   v-show="doctor.sourcesurplus===0">
                                                            <h3>剩余 {{doctor.sourcesurplus}}</h3>
                                                        </el-button>
                                                    </el-descriptions-item>
                                                </el-descriptions>
                                                <div style="margin-top: 20px;color:#000;" v-else>
                                                    <p>当天已无号，请查看其它日期号源</p>
                                                </div>
                                            </el-col>
                                        </el-row>
                                    </el-col>
                                </el-row>
                            </el-card>
                        </el-col>
                    </el-row>
                </el-col>
            </el-row>
            <!--对话框 点击预约挂号时候弹出-->
            <el-dialog
                    title="挂号信息"
                    :visible.sync="dialogVisible"
                    width="25%">
                <el-row v-if="registeredCode===0">
                    <el-col>
                        <p style="font-weight: bold;">选择就诊人：</p>
                    </el-col>
                    <el-col style="margin: 20px 0 20px 20px;">
                        <el-link class="user-card" @click="checkConfirmUser">
                            <!--关闭子用户-->
                            <el-card shadow="hover" class="defaultUserCard" v-if="userSwitch">
                                <div>
                                    <div><p>{{localStorage.getItem("currentNickName")}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="el-icon-success"></i></p></div>
                                    <div style="margin-top: 10px;"><p>176***6395</p></div>
                                </div>
                            </el-card>
                            <!--开启子用户-->
                            <el-card shadow="hover" v-else>
                                <div>
                                    <div><p>{{localStorage.getItem("currentNickName")}}</p></div>
                                    <div style="margin-top: 10px;"><p>176***6395</p></div>
                                </div>
                            </el-card>
                        </el-link>
<!--                        <el-link class="add-card">-->
<!--                            <el-link @click="patientsDialogVisible=true">-->
<!--                                <el-card shadow="hover">-->
<!--                                    <div>-->
<!--                                        <div><p style="color: #4990f1;">+ 添加就诊人</p></div>-->
<!--                                        <div style="margin-top: 10px;"><p>联系人信息</p></div>-->
<!--                                    </div>-->
<!--                                </el-card>-->
<!--                            </el-link>-->
<!--                        </el-link>-->
                    </el-col>
                    <!--默认为本用户-->
                    <el-col style="margin-bottom: 10px;">
<!--                        <el-switch-->
<!--                                v-model="userSwitch"-->
<!--                                inactive-text="子用户"-->
<!--                                active-text="本用户">-->
<!--                        </el-switch>-->
                    </el-col>
                    <!--展示子用户-->
<!--                    <el-col style="margin-bottom: 10px;" v-show="!userSwitch">-->
<!--                        <el-radio-group v-model="childUser">-->
<!--                            <el-radio-button v-for="child in childUsers" :label="child.nickname"></el-radio-button>-->
<!--                        </el-radio-group>-->
<!--                    </el-col>-->
                    <el-col v-if="registeredCode===0">
                        <p style="font-weight: bold;">挂号信息：</p>
                    </el-col>
                    <el-col v-if="registeredCode===0">
                        <div class="dialog-div">
                            <el-descriptions :column="1" class="dialog-descriptions">
                                <el-descriptions-item label="预约日期">{{dialogData.frameTime}}</el-descriptions-item>
                                <el-descriptions-item label="预约时间">
                                    {{dialogData.startTime}}
                                    <span style="font-weight: bold;">&nbsp;~&nbsp;</span>
                                    {{dialogData.endTime}}
                                </el-descriptions-item>
                                <el-descriptions-item label="选择时间">
                                    <el-time-select
                                            v-model="bookingTime"
                                            :picker-options="{
                                                start: dialogData.startTime.substring(0, dialogData.endTime.length - 3),
                                                step: '00:30',
                                                end: dialogData.endTime.substring(0, dialogData.endTime.length - 3),
                                                }"
                                            placeholder="选择时间">
                                    </el-time-select>
                                </el-descriptions-item>
                                <el-descriptions-item label="就诊科室">{{dialogData.deptname}}</el-descriptions-item>
                                <el-descriptions-item label="就诊医生">{{dialogData.nickname}}</el-descriptions-item>
                                <el-descriptions-item label="服务费用">{{dialogData.expenses}}</el-descriptions-item>
                            </el-descriptions>
                        </div>
                    </el-col>
                </el-row>
                <!--挂号成功/失败提示框-->
                <el-row v-if="registered"  v-loading="loading">
                    <el-col >
                        <el-result v-show="registeredCode===2003" icon="success" :title="registeredMsg">
                            <template slot="subTitle">
                                <el-link type="primary" :underline="false" href="/beforeIndex/registeredManage.html">【查看预约信息】</el-link>
                            </template>
                        </el-result>
                        <el-result v-show="registeredCode===2004" icon="error" :title="registeredMsg">
                            <template slot="subTitle">
                                <el-link type="primary" :underline="false" href="/beforeIndex/registeredManage.html">【查看预约信息】</el-link>
                            </template>
                        </el-result>
                        <el-result v-show="registeredCode===timeErrorCode" icon="info" :title="registeredMsg">
                            <template slot="subTitle"></template>
                        </el-result>
                    </el-col>
                </el-row>
                <span slot="footer" class="dialog-footer" v-if="bookingStatus===false">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="confirmRegistered()">确认挂号</el-button>
                </span>
            </el-dialog>
            <!--添加就诊人弹窗-->
            <el-dialog title="就诊人信息" :visible.sync="patientsDialogVisible" width="30%" center>
                <el-form @submit.native.prevent :model="patientsForm" status-icon :rules="patientsRules"
                         ref="patientsForm" label-width="80px">
                    <el-form-item label="姓名" prop="nickname">
                        <el-input v-model="patientsForm.nickname"></el-input>
                    </el-form-item>
                    <el-form-item label="性别">
                        <el-radio v-model="patientsForm.gender" label="1">男</el-radio>
                        <el-radio v-model="patientsForm.gender" label="0">女</el-radio>
                    </el-form-item>
                    <el-form-item label="出生日期" prop="birthday">
                        <el-date-picker
                                value-format="yyyy-MM-dd"
                                v-model="patientsForm.birthday"
                                type="date"
                                placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="地址">
                        <el-input v-model="patientsForm.address"></el-input>
                    </el-form-item>
                    <el-form-item label="手机号" prop="phone">
                        <el-input v-model="patientsForm.phone"></el-input>
                    </el-form-item>
                    <el-form-item label="工作">
                        <el-input v-model="patientsForm.job"></el-input>
                    </el-form-item>
                    <el-form-item label="提示">
                        <span>该操作表示为当前账号添加就诊人，一个账号可以添加多个就诊人，最多可以保存四个就诊人信息</span>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="submitPatientsForm">确 定</el-button>
                </div>
            </el-dialog>
        </el-main>
        <!--自定义标签-->
        <el-footer>
            <index-footer></index-footer>
        </el-footer>
    </el-container>
</div>
</body>
<!-- 引入Vue和Element UI库 -->
<script src="/js/vue.js"></script>
<script src="/element/element-ui.js"></script>
<!--引入axios框架文件-->
<script src="/js/axios.js"></script>
<!--引入自定义header-->
<script src="/js/index-header.js"></script>
<!--引入自定义footer-->
<script src="/js/index-footer.js"></script>
<!--引入自定义卡片card-->
<script src="/js/index-left-card.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: function () {
            return {
                //自定义状态码 时间错误
                timeErrorCode: 6000,
                loading: false,
                deptId: null,
                deptname: '',
                //排班数据
                futureData: [],
                futureWeek: [],
                //医生排班数据
                doctorData: [],
                // 日期卡片默认激活
                cardActive: 0,
                not_count: 0,
                have_count: 0,
                //号源序号
                sourceIndex: 0,
                //弹窗是否显示
                dialogVisible: false,
                //就诊人弹窗
                patientsDialogVisible: false,
                //卡片数据
                dialogData: {
                    //开始时间
                    startTime: '',
                    //结束时间
                    endTime: '',
                    //科室名称
                    deptname: '',
                    //挂号费用
                    expenses: 0,
                    //用户账号
                    username: '',
                    //当前日期 年月日 时间
                    frameTime: '',
                },
                //选择默认就诊人
                checkConfirmUser: true,
                //预约数据
                bookingData: {
                    username: localStorage.getItem("currentUsername"),
                    nickName: '',
                    deptName: '',
                    doctorNo: '',
                    //号源id
                    sourceId: '',
                    date: '',
                },
                //确认挂号后提示
                registered: false,
                //挂号状态提示
                registeredCode: 0,
                registeredMsg: '',
                //用户预约时间
                bookingTime: '',
                //返回状态码
                dataCode: '',
                //就诊人表单
                patientsForm: {
                    nickname: '',
                    gender: '',
                    birthday: '',
                    address: '',
                    phone: '',
                    job: '',
                    parentUser:localStorage.getItem("currentUsername"),
                },
                //子用户
                childUsers: [],
                //就诊人验证规则
                patientsRules: {
                    nickname: [
                        {required: true, message: '请输入姓名', trigger: 'blur'},
                        {min: 2, max: 15, message: '长度在 2 到 15 个字符', trigger: 'blur'}
                    ],
                    birthday: [
                        {required: true, message: '请输入出生日期', trigger: 'blur'}
                    ],
                    phone: [
                        {required: true, message: '请输入手机号码', trigger: 'blur'},
                        {pattern: /^1[3456789]\d{9}$/, message: '手机号格式不正确', trigger: 'blur'}
                    ],
                },
                //用户开关
                userSwitch: true,
                //选择的子用户
                childUser: '',
                //预约状态
                bookingStatus: false,
            }
        },
        methods: {
            //获取请求的参数
            getUrlKey(name, url) {
                return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null
            },
            //获取排班日期数据 根据科室获取
            getFutureDate() {
                this.deptId = this.getUrlKey('deptId', window.location.href);
                if (this.deptId !== null) {
                    axios.get("/pa/appoint/byDeptId/" + this.deptId).then(function (res) {
                        v.dataCode = res.data.code;
                        if (res.data.code === 1) {
                            v.futureData = res.data.data;
                            //加载默认数据 如果科室不为空加载科室、如果医生编号不为空加载医生
                            if (v.deptId !== null) {
                                v.getDoctorSource(v.deptId, v.futureData[v.cardActive].schedulTime);
                            } else {
                                v.getFutureDateByDoctor();
                            }
                            //TODO 下班后按钮点击按钮 显示无法预约

                            //数据加载成功开始解析数据
                            v.parseDate(v.futureData);
                            v.deptname = v.futureData[0].deptname;
                        }
                        if (res.data.code === 1007) {
                            v.loading = false;
                        }
                    })
                }
            },
            //获取排班日期数据 根据科室获取
            getFutureDateByDoctor() {
                let doctorNo = this.getUrlKey('doctorNo', window.location.href);
                if (doctorNo !== null) {
                    //根据医生工号查询科室
                    axios.get("/pa/appoint/byDoctorNo/" + doctorNo).then(function (res) {
                        v.dataCode = res.data.code;
                        if (res.data.code === 1) {
                            if (v.futureData.length === 0) {
                                v.futureData = res.data.data;
                                //根据二级科室名称查询科室id
                                axios.get("/pa/dept/getDeptIdByDeptName/" + v.futureData[v.cardActive].deptname).then(function (res) {
                                    if (res.data.code === 1) {
                                        v.deptId = res.data.data;
                                        v.getDoctorByDoctorNo(doctorNo, v.futureData[v.cardActive].schedulTime);
                                        //TODO 下班后按钮点击按钮 显示无法预约
                                    }
                                })
                            }
                        }
                        if (res.data.code === 1007) {
                            v.loading = false;
                        }
                        v.parseDate(v.futureData);
                        v.deptname = v.futureData[0].deptname;
                    })
                }
            },
            //获取医生的排班数据 根据科室id
            getDoctorSource(deptId, futureData) {
                axios.get("/pa/doctor/queryByDeptId/" + deptId + "/ByDate/" + futureData).then(function (res) {
                    if (res.data.code === 1) {
                        v.doctorData = res.data.data;
                    }
                })
            },
            //获取医生的排班数据号源数据 根据医生工号
            getDoctorByDoctorNo(doctorNo, futureData) {
                console.log("请求日期：" + futureData);
                if (futureData != null) {
                    axios.get("/pa/doctor/queryByDoctorNo/" + doctorNo + "/ByDate/" + futureData).then(function (res) {
                        if (res.data.code === 1) {
                            v.doctorData = res.data.data;
                        }
                    })
                }
            },
            //解析日期 并获取号源
            parseDate(futureData) {
                for (let i = 0; i < futureData.length; i++) {
                    let date = new Date(Date.parse(futureData[i].schedulTime));
                    let month = date.getMonth() + 1;
                    let day = date.getDate();
                    let week = date.getDay();
                    let weekStr = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][week];
                    //号源数量
                    let total = futureData[i].sourcetotal;
                    let surplus = futureData[i].sourcesurplus;
                    let str = {
                        "date": `${month}月${day}日`,
                        "week": `${weekStr}`,
                        "totalCount": total,
                        "surplus": surplus
                    };
                    v.futureWeek.push(str);
                }
            },
            //对话框确认挂号事件
            confirmRegistered() {
                let startTime = v.doctorData[v.sourceIndex].frameTime;
                let endTime = v.doctorData[v.sourceIndex].endTime;
                let nowTime = new Date().toLocaleTimeString();
                // let flag = v.checkBookingStatus(nowTime, startTime, endTime);
                // if (flag.status) {
                if (true) {
                    //发送预约请求
                    //封装预约信息
                    v.bookingData.sourceId = v.doctorData[v.sourceIndex].sourceId;
                    console.log("号源id：" + v.doctorData[v.sourceIndex].sourceId);
                    v.bookingData.deptName = v.doctorData[v.sourceIndex].deptname;
                    v.bookingData.doctorNo = v.doctorData[v.sourceIndex].doctorNo;
                    //解析时间字符串
                    v.bookingData.date = v.doctorData[v.sourceIndex].schedulTime + " " + v.bookingTime+":00";
                    //当前用户名
                    if (v.userSwitch) {
                        v.bookingData.nickName = localStorage.getItem("currentNickName");
                    } else {
                        v.bookingData.nickName = v.childUser;
                        if (v.bookingData.nickName===''){
                            v.$message.info("您还没选择用户，请选择用户后再预约！");
                            return;
                        }
                    }
                    v.sendBookingData(v.bookingData);
                    //弹出提示
                    v.registered = true;
                }
                //提示内容
                v.registeredCode = v.timeErrorCode;
                //弹出提示
                v.registered = true;
            },
            //设置有号和无号样式
            setDateCardStyle(futureData) {
                for (let i = 0; i < futureData.length; i++) {
                    let element = document.getElementById('dataSource_' + i);
                    //设置有号样式
                    if (futureData[i].sourcetotal > 0 && futureData[i].sourcesurplus > 0) {
                        element.classList.add("orders_card_have");
                    }
                    //当天满号样式
                    if (futureData[i].sourcetotal > 0 && futureData[i].sourcesurplus === 0 && i===0){
                        element.classList.remove("orders_card_have_active");
                        element.classList.add("orders_card_today_null_full");
                    }
                    //设置当天样式
                    if (futureData[i].sourcetotal > 0 && i === 0) {
                        element.classList.add("orders_card_have_active");
                    }
                    //无号点击样式
                    if (futureData[i].sourcetotal === 0 && i === 0) {
                        element.classList.add("orders_card_today_null_full");
                    }

                }
            },
            //设置点击样式
            setClickCardStyle(i) {
                v.cardActive = i;
                //请求号源数据
                let doctorNo = this.getUrlKey('doctorNo', window.location.href);
                this.deptId = this.getUrlKey('deptId', window.location.href);
                if (this.deptId !== null && v.futureData[i].schedulTime !== null) {
                    v.getDoctorSource(v.deptId, v.futureData[i].schedulTime);
                }
                if (doctorNo !== null && v.futureData[i].schedulTime !== null) {
                    v.getDoctorByDoctorNo(doctorNo, v.futureData[i].schedulTime);
                }
                v.setDateCardStyle(v.futureData);
            },
            //预约按钮
            booking(i) {
                v.sourceIndex = i;
                //如果有预约
                v.dialogVisible = true;
                //点击确认挂号重置状态码
                v.registeredCode = 0;
                let now = new Date();
                //获取当前日期
                let year = now.getFullYear() + "年";
                let month = now.getMonth() + 1 + "月";
                let date = now.getDate() + "日"
                let hour = now.getHours() + ":" + now.getMinutes();
                let dateString = year + month + date + " " + hour;
                //更新对话框信息
                v.dialogData.deptname = v.doctorData[i].deptname;
                v.dialogData.nickname = v.doctorData[i].nickname;
                v.dialogData.frameTime = dateString;
                v.dialogData.expenses = v.doctorData[i].expenses;
                v.dialogData.startTime = v.doctorData[i].frameTime;
                v.dialogData.endTime = v.doctorData[i].endTime;
                //显示默认预约时间
                v.bookingTime = v.doctorData[i].frameTime.substring(0,v.doctorData[i].frameTime.length-3);
                //获取子用户
                v.listChildUsers();
            },
            //发送预约请求
            sendBookingData(bookingData) {
                v.loading=true;
                let now = new Date();
                let year = now.getFullYear();
                let month = now.getMonth() + 1;
                let day = now.getDate();
                now = year+":"+month+":"+day;
                let timeItem=localStorage.getItem("bookingStatus");
                let username=localStorage.getItem("currentUsername");
                if (timeItem===now+username){
                    v.bookingStatus = false;
                    v.registeredCode = v.timeErrorCode;
                    v.registeredMsg = "您今日已预约，请改日再约";
                    return;
                }
                axios.post("/pa/booking/registered", bookingData, {headers: {token: localStorage.getItem("localJwt")}}).then(function (res) {
                    this.deptId = v.getUrlKey('deptId', window.location.href);
                    if (res.data.code===0){
                        v.$message.info("请选择预约的时间");
                        return;
                    }
                    if (res.data.code === 2003) {
                            //预约成功状态
                            v.bookingStatus = true;
                            localStorage.setItem("bookingStatus",now+username);
                            //预约成功
                            v.registeredCode = res.data.code;
                            v.registeredMsg = res.data.msg;
                    } else {
                        v.registeredCode = res.data.code;
                        v.registeredMsg = res.data.msg;
                    }
                })
                v.loading=false;
            },
            //判断当前时间是否可以进行预约
            checkBookingStatus(nowTime, startTime, endTime) {
                let result = {msg: null, status: true};
                if (nowTime > endTime) {
                    result.msg = "时间太晚了，请明天再预约。";
                    result.status = false;
                    return result;
                } else if (nowTime < startTime) {
                    result.msg = "时间太早了，请稍后再预约。";
                    result.status = false;
                    return result;
                }
                return result;
            },
            //解析时间 字符串转date
            parseDateTime(dateTimeStr) {
                const [dateStr, timeStr] = dateTimeStr.split(' ');
                const [day, month, year] = dateStr.split('-');
                const [hours, minutes, seconds] = timeStr.split(':');
                return new Date(year, month - 1, day, hours, minutes, seconds);
            },
            //表单提交
            //添加就诊人表单
            submitPatientsForm() {
                this.$refs.patientsForm.validate((valid) => {
                    if (valid) {
                        //为当前账号添加用户
                        axios.post("/pa/userChild/insert", v.patientsForm,{headers: {token: localStorage.getItem("localJwt")}}).then(function (res) {
                            if (res.data.data === 1) {
                                //数据添加成功
                                v.$message.info("用户添加成功");
                                //清除表单
                                v.patientsForm = [];
                            } else {
                                v.$message.error(res.data.msg);
                            }
                        })
                    } else {
                        //表单验证不通过
                        v.$message.error("表单验证不通过");
                    }
                });
            },
            //获取当前账号子用户
            listChildUsers() {
                axios.get("/pa/userChild/listChildUsers/" + localStorage.getItem("currentUsername"), {headers: {token: localStorage.getItem("localJwt")}}).then(function (res) {
                    if (res.data.code === 1) {
                        v.childUsers = res.data.data;
                        //默认选中第一个
                        v.childUser=v.childUsers[0].nickname;
                        return;
                    }
                    v.$message.error(res.data.msg);
                })
            },
        },
        updated() {
            this.setDateCardStyle(v.futureData);
            v.loading = false;
        }
        ,
        mounted() {
            this.deptId = this.getUrlKey('deptId', window.location.href);
            if (this.deptId !== null) {
                this.getFutureDate();
            } else {
                this.getFutureDateByDoctor();
            }
        }
        ,
        created() {
            this.loading = true;
        }
        ,
        watch: {}
    })
</script>
</html>
